<?php $this->pageHeader('Brukere'); ?>

<?php echo $this->flashMessage()->renderMessages(); ?>

<div class="header_wrapper">
    <h1>Brukere</h1>
    <?php echo $this->filterForm; ?>
</div>

<table class="admin_users">
    <thead>
        <tr>
            <th>Navn</th>
            <th>Brukernavn</th>
            <th>Medlem av</th>
            <th class="confirmed">Bekreftet</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
<?php
    $rowHighlight = false;
    foreach($this->users as $user) {
        $memberName = $this->escape($user['Member']['first_name'] . ' ' . $user['Member']['last_name']);
?>
    <tr>
        <td><a href="<?php echo $this->url(array('module' => 'core', 'controller' => 'user', 'action' => 'view', 'id' => $user['id']), null, true); ?>"><?php echo $memberName; ?></a></td>
        <td><?php echo $this->escape($user['username']); ?></td>
        <td>
        <?php
            $groups = '';
            foreach($user['Groups'] as $group) {
                $groups .= $group['name'] . ', ';
            }
            echo $this->escape(substr($groups, 0, -2));
        ?>
        </td>
        <td class="confirmed">
        <?php if($user['is_confirmed'] == 1) : ?>
            <img src="<?php echo $this->imageLink('images/icons/tick.png'); ?>" alt="<?php echo $this->escape($user['username']); ?> er aktivert" title="Bekreftet" />
        <?php else : ?>
            <img src="<?php echo $this->imageLink('images/icons/cross.png'); ?>" alt="<?php echo $this->escape($user['username']); ?> er ikke aktivert" title"Ikke bekreftet" />
        <?php endif; ?>
        </td>
    <td class="confirm_user">
        <?php if ($user['is_confirmed'] == 0) : ?>
            <a href="<?php echo $this->url(array('module' => 'admin', 'controller' => 'user', 'action' => 'confirm', 'id' => $user['id']), null, true); ?>"><img src="<?php echo $this->imageLink('images/icons/accept.png'); ?>" alt="Aktiver <?php echo $this->escape($user['username']); ?>" title="Bekreft" /></a>
        <?php endif; ?>
        </td>
  </tr>
<?php
    }
?>
    </tbody>
</table>
<?php echo $this->paginationLinks; ?>
